home *** CD-ROM | disk | FTP | other *** search
/ Freelog 47 / Freelog047.iso / Bas / Jeu / Aitchu / Aitchu[1].swf / scripts / frame_37 / DoAction.as
Text File  |  2003-06-10  |  27KB  |  905 lines

  1. function CSprite(SpriteMovieClip, ShurikenMovieClip, KeyUp, KeyDown, KeyLeft, KeyRight, KeyShuriken, KeySabre, LivesValue, PowerByLife)
  2. {
  3.    var CptArray;
  4.    this.NumOfLives = LivesValue;
  5.    this.MaxOfPower = PowerByLife;
  6.    this.NumOfPower = this.MaxOfPower;
  7.    this.XStep = 5;
  8.    this.YStep = 5;
  9.    this.SwimValue = 0;
  10.    this.ArrayCounter = 0;
  11.    this.JumpArray = new Array(20,16,8,0,-8,-16,-20);
  12.    this.WallJumpArray = new Array(0,15,15,15,15,15,15,15,15);
  13.    this.StepArray = new Array(G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING);
  14.    this.ShurikensArray = new Array();
  15.    this.NumOfShurikens = 5;
  16.    this.ShurikensSpeed = this.XStep * 3;
  17.    CptArray = 0;
  18.    while(CptArray < G_MAX_NUM_SHURIKENS)
  19.    {
  20.       duplicateMovieClip(ShurikenMovieClip,"Shuriken" + (CptArray + 1),16384 + (CptArray + 1));
  21.       this.ShurikensArray.push(eval("Shuriken" + (CptArray + 1)));
  22.       this.ShurikensArray[CptArray]._visible = 0;
  23.       this.ShurikensArray[CptArray].XDirection = 0;
  24.       CptArray++;
  25.    }
  26.    this.HitPlatforms = 0;
  27.    this.HitWater = 0;
  28.    this.HitPlatformNum = 0;
  29.    this.HitWallNum = 0;
  30.    this.ThrowShuriken = 0;
  31.    this.SabreHit = 0;
  32.    this.Direction = G_RIGHT_DIRECTION;
  33.    this.Movement = 4;
  34.    this.BlinkValue = 0;
  35.    this.TouchByEnemyValue = 0;
  36.    this.PrevIsJumpingUp = 0;
  37.    this.IsJumpingUp = 0;
  38.    this.PrevIsJumpingDown = 0;
  39.    this.IsJumpingDown = 0;
  40.    this.PrevLeftMove = 0;
  41.    this.NextLeftMove = 0;
  42.    this.PrevRightMove = 0;
  43.    this.NextRightMove = 0;
  44.    this.UpKey = KeyUp;
  45.    this.DownKey = KeyDown;
  46.    this.LeftKey = KeyLeft;
  47.    this.RightKey = KeyRight;
  48.    this.ShurikenKey = KeyShuriken;
  49.    this.SabreKey = KeySabre;
  50.    this.SabreKeyRelease = 1;
  51.    this.Clip = SpriteMovieClip;
  52.    this.ClipRightStep = 1;
  53.    this.ClipLeftStep = 10;
  54.    this.ClipRightBreak = 20;
  55.    this.ClipLeftBreak = 30;
  56.    this.ClipRightStepJump = 40;
  57.    this.ClipRightJump = 50;
  58.    this.ClipLeftStepJump = 60;
  59.    this.ClipLeftJump = 70;
  60.    this.ClipFall = 80;
  61.    this.ClipRightStepFall = 90;
  62.    this.ClipLeftStepFall = 100;
  63.    this.ClipRightSwim = 110;
  64.    this.ClipLeftSwim = 120;
  65.    this.ClipUpRightSwim = 130;
  66.    this.ClipUpLeftSwim = 140;
  67.    this.ClipDownRightSwim = 150;
  68.    this.ClipDownLeftSwim = 160;
  69.    this.ClipRightSwimBreak = 170;
  70.    this.ClipLeftSwimBreak = 180;
  71.    this.ClipWallToRightJump = 190;
  72.    this.ClipWallToLeftJump = 200;
  73.    this.ClipWallToRightBreak = 210;
  74.    this.ClipWallToLeftBreak = 220;
  75.    this.ClipRightThrowShurikenBreak = 230;
  76.    this.ClipLeftThrowShurikenBreak = 240;
  77.    this.ClipRightSabreBreak = 250;
  78.    this.ClipLeftSabreBreak = 260;
  79. }
  80. var G_SCREEN_WIDTH = 400;
  81. var G_SCREEN_HEIGHT = 600;
  82. var G_ALT_KEY = 18;
  83. var G_ENEMY_SCORE_VALUE = 150;
  84. var G_BOSS_SCORE_VALUE = G_ENEMY_SCORE_VALUE * 20;
  85. var G_BOSS_BLINK_VALUE = 10;
  86. var G_LEFT_DIRECTION = 0;
  87. var G_RIGHT_DIRECTION = 1;
  88. var G_MOVE_UP_LEFT = 0;
  89. var G_MOVE_UP = 1;
  90. var G_MOVE_UP_RIGHT = 2;
  91. var G_MOVE_LEFT = 3;
  92. var G_NO_MOVEMENT = 4;
  93. var G_MOVE_RIGHT = 5;
  94. var G_MOVE_DOWN_LEFT = 6;
  95. var G_MOVE_DOWN = 7;
  96. var G_MOVE_DOWN_RIGHT = 8;
  97. var G_STEP_WHEN_JUMPING = 8;
  98. var G_NUM_SHURIKENS_BONUS = 10;
  99. var G_MAX_NUM_SHURIKENS = 15;
  100. var G_RANDOM_BONUS_SHURIKENS = 15;
  101. var G_POWER_BY_LIFE = 2;
  102. var G_NUM_OF_BLINKS = 30;
  103. var G_START_POSITION_X = 75;
  104. var G_START_POSITION_Y = 300;
  105. CSprite.prototype.IsHittingClip = function(MovieClip)
  106. {
  107.    var SpriteBounds = this.Clip.getBounds(_root);
  108.    return MovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || MovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || MovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true) || MovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || MovieClip.hitTest(this.Clip._x,this.Clip._y,true);
  109. };
  110. CSprite.prototype.IsHittingDeathPlatforms = function(DeathPlatformsClipArray)
  111. {
  112.    var HitValue;
  113.    var SpriteBounds = this.Clip.getBounds(_root);
  114.    var Cpt;
  115.    HitValue = 0;
  116.    Cpt = 0;
  117.    while(!HitValue && Cpt < DeathPlatformsClipArray.length)
  118.    {
  119.       HitValue = DeathPlatformsClipArray[Cpt].hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || DeathPlatformsClipArray[Cpt].hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true);
  120.       Cpt++;
  121.    }
  122.    return HitValue;
  123. };
  124. CSprite.prototype.IsGettingShurikens = function(ShurikensMovieClip)
  125. {
  126.    var NumShurikensTmp;
  127.    var HitValue;
  128.    var ShurikensBounds = ShurikensMovieClip.getBounds(_root);
  129.    var ClipCurrentFrame = ShurikensMovieClip._currentFrame;
  130.    HitValue = this.Clip.hitTest(ShurikensBounds.xMin,ShurikensBounds.yMin,true) || this.Clip.hitTest(ShurikensBounds.xMax,ShurikensBounds.yMin,true) || this.Clip.hitTest(ShurikensBounds.xMin,ShurikensBounds.yMax,true) || this.Clip.hitTest(ShurikensBounds.xMax,ShurikensBounds.yMax,true);
  131.    if(ClipCurrentFrame >= 15 && 35 >= ClipCurrentFrame && HitValue)
  132.    {
  133.       ShurikensMovieClip.gotoAndPlay("ShurikensClipEnd");
  134.       NumShurikensTmp = this.NumOfShurikens + G_NUM_SHURIKENS_BONUS;
  135.       if(G_MAX_NUM_SHURIKENS < NumShurikensTmp)
  136.       {
  137.          this.NumOfShurikens = G_MAX_NUM_SHURIKENS;
  138.       }
  139.       else
  140.       {
  141.          this.NumOfShurikens += G_NUM_SHURIKENS_BONUS;
  142.       }
  143.       return 1;
  144.    }
  145.    return 0;
  146. };
  147. CSprite.prototype.SpriteInit = function(XPos, YPos)
  148. {
  149.    this.Clip._x = XPos;
  150.    this.Clip._y = YPos;
  151.    this.Move(G_NO_MOVEMENT);
  152. };
  153. CSprite.prototype.IsJumping = function()
  154. {
  155.    var ClipFrame = this.Clip._currentFrame;
  156.    return (ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightJump || ClipFrame == this.ClipLeftJump || ClipFrame == this.ClipLeftStepJump) && !this.FallValue;
  157. };
  158. CSprite.prototype.IsJumpingDown = function()
  159. {
  160.    return 0 >= this.JumpArray[this.ArrayCounter];
  161. };
  162. CSprite.prototype.IsEndOfJump = function()
  163. {
  164.    return this.ArrayCounter == this.JumpArray.length;
  165. };
  166. CSprite.prototype.IsFalling = function()
  167. {
  168.    var ClipFrame = this.Clip._currentFrame;
  169.    return ClipFrame == this.ClipFall || ClipFrame == this.ClipRightStepFall || ClipFrame == this.ClipLeftStepFall;
  170. };
  171. CSprite.prototype.IsHittingPlatformsArray = function(PlatformsMovieClipArray)
  172. {
  173.    var SpriteBounds = this.Clip.getBounds(_root);
  174.    var ClipFrame = this.Clip._currentFrame;
  175.    var HitTestValue;
  176.    var CptArray;
  177.    var CurrentPlatform;
  178.    var MiddleClip;
  179.    if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipLeftStepFall)
  180.    {
  181.       SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  182.    }
  183.    if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightStepFall)
  184.    {
  185.       SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  186.    }
  187.    MiddleClip = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  188.    HitTestValue = 0;
  189.    CptArray = 0;
  190.    while(CptArray < PlatformsMovieClipArray.length && !HitTestValue)
  191.    {
  192.       CurrentPlatform = PlatformsMovieClipArray[CptArray];
  193.       HitTestValue = CurrentPlatform.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || CurrentPlatform.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || CurrentPlatform.hitTest(MiddleClip,SpriteBounds.yMax,true);
  194.       CptArray++;
  195.    }
  196.    if(HitTestValue)
  197.    {
  198.       CptArray--;
  199.       this.HitPlatformNum = CptArray;
  200.    }
  201.    return HitTestValue;
  202. };
  203. CSprite.prototype.IsHittingMovingPlatform = function(MovingPlatformMovieClip)
  204. {
  205.    var SpriteBounds = this.Clip.getBounds(_root);
  206.    var ClipFrame = this.Clip._currentFrame;
  207.    var HitTestValue;
  208.    var CptArray;
  209.    var CurrentPlatform;
  210.    var MiddleClip;
  211.    if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipLeftStepFall)
  212.    {
  213.       SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  214.    }
  215.    if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightStepFall)
  216.    {
  217.       SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  218.    }
  219.    MiddleClip = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  220.    return MovingPlatformMovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || MovingPlatformMovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || MovingPlatformMovieClip.hitTest(MiddleClip,SpriteBounds.yMax,true);
  221. };
  222. CSprite.prototype.AdjustClipOnPlatform = function(PlatformsMovieClipArray)
  223. {
  224.    var CurrentPlatform;
  225.    var SpriteBounds = this.Clip.getBounds(_root);
  226.    CurrentPlatform = PlatformsMovieClipArray[this.HitPlatformNum];
  227.    this.Clip._y += CurrentPlatform._y - SpriteBounds.yMax;
  228. };
  229. CSprite.prototype.IsHittingPlatformsJumpingDown = function(PlatformsMovieClip)
  230. {
  231.    var SpriteBounds = this.Clip.getBounds(_root);
  232.    var ClipFrame = this.Clip._currentFrame;
  233.    var JumpDown;
  234.    var Val;
  235.    if(ClipFrame == this.ClipLeftStepJump)
  236.    {
  237.       SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  238.    }
  239.    if(ClipFrame == this.ClipRightStepJump)
  240.    {
  241.       SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  242.    }
  243.    return PlatformsMovieClip.hitTest(SpriteBounds.xMin,Cpt,true) || PlatformsMovieClip.hitTest(SpriteBounds.xMax,Cpt,true);
  244. };
  245. CSprite.prototype.IsHittingWater = function(WaterMovieClip)
  246. {
  247.    var SpriteBounds = this.Clip.getBounds(_root);
  248.    return WaterMovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || WaterMovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true);
  249. };
  250. CSprite.prototype.StartJump = function(JumpMvtKey)
  251. {
  252.    this.ArrayCounter = 0;
  253.    if(JumpMvtKey == G_MOVE_UP_LEFT)
  254.    {
  255.       this.Direction = G_LEFT_DIRECTION;
  256.       this.Clip.gotoAndStop(this.ClipLeftStepJump);
  257.       this.Clip._x -= this.StepArray[this.ArrayCounter];
  258.    }
  259.    else if(JumpMvtKey == G_MOVE_UP_RIGHT)
  260.    {
  261.       this.Direction = G_RIGHT_DIRECTION;
  262.       this.Clip.gotoAndStop(this.ClipRightStepJump);
  263.       this.Clip._x += this.StepArray[this.ArrayCounter];
  264.    }
  265.    else if(this.Direction == G_LEFT_DIRECTION)
  266.    {
  267.       this.Clip.gotoAndStop(this.ClipLeftJump);
  268.    }
  269.    else
  270.    {
  271.       this.Clip.gotoAndStop(this.ClipRightJump);
  272.    }
  273.    this.Clip._y -= this.JumpArray[this.ArrayCounter];
  274.    this.ArrayCounter = this.ArrayCounter + 1;
  275. };
  276. CSprite.prototype.Jump = function()
  277. {
  278.    var ClipFrame = this.Clip._currentFrame;
  279.    if(ClipFrame == this.ClipLeftStepJump)
  280.    {
  281.       this.Clip._x -= this.StepArray[this.ArrayCounter];
  282.    }
  283.    if(ClipFrame == this.ClipRightStepJump)
  284.    {
  285.       this.Clip._x += this.StepArray[this.ArrayCounter];
  286.    }
  287.    this.Clip._y -= this.JumpArray[this.ArrayCounter];
  288.    this.ArrayCounter = this.ArrayCounter + 1;
  289. };
  290. CSprite.prototype.StartFall = function()
  291. {
  292.    var ClipFrame = this.Clip._currentFrame;
  293.    if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipWallToLeftJump)
  294.    {
  295.       this.Clip.gotoAndStop(this.ClipLeftStepFall);
  296.       this.Clip._x -= G_STEP_WHEN_JUMPING;
  297.    }
  298.    else if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipWallToRightJump)
  299.    {
  300.       this.Clip.gotoAndStop(this.ClipRightStepFall);
  301.       this.Clip._x += G_STEP_WHEN_JUMPING;
  302.    }
  303.    else
  304.    {
  305.       this.Clip.gotoAndStop(this.ClipFall);
  306.    }
  307.    this.Clip._y += this.YStep * 3;
  308. };
  309. CSprite.prototype.Fall = function()
  310. {
  311.    var ClipFrame = this.Clip._currentFrame;
  312.    if(ClipFrame == this.ClipLeftStepFall)
  313.    {
  314.       this.Clip._x -= G_STEP_WHEN_JUMPING;
  315.       this.Clip._y += this.YStep * 3;
  316.    }
  317.    else if(ClipFrame == this.ClipRightStepFall)
  318.    {
  319.       this.Clip._x += G_STEP_WHEN_JUMPING;
  320.       this.Clip._y += this.YStep * 3;
  321.    }
  322.    else
  323.    {
  324.       this.Clip._y += this.YStep * 3;
  325.    }
  326. };
  327. CSprite.prototype.IsSwimming = function()
  328. {
  329.    return this.SwimValue;
  330. };
  331. CSprite.prototype.ApplyPlouf = function(WaterMovieClip, PloufMovieClip)
  332. {
  333.    var WaterBounds = WaterMovieClip.getBounds(_root);
  334.    PloufMovieClip._x = this.Clip._x;
  335.    PloufMovieClip._y = this.Clip._y - 42;
  336.    PloufMovieClip.play();
  337. };
  338. CSprite.prototype.EndSwim = function()
  339. {
  340.    this.SwimValue = 0;
  341. };
  342. CSprite.prototype.Swim = function(SwimValue)
  343. {
  344.    var ClipFrame = this.Clip._currentFrame;
  345.    if(SwimValue == G_MOVE_LEFT)
  346.    {
  347.       this.Direction = G_LEFT_DIRECTION;
  348.       if(ClipFrame != this.ClipLeftSwim)
  349.       {
  350.          this.Clip.gotoAndStop(this.ClipLeftSwim);
  351.       }
  352.       this.Clip._x -= this.XStep / 2;
  353.    }
  354.    else if(SwimValue == G_MOVE_RIGHT)
  355.    {
  356.       this.Direction = G_RIGHT_DIRECTION;
  357.       if(ClipFrame != this.ClipRightSwim)
  358.       {
  359.          this.Clip.gotoAndStop(this.ClipRightSwim);
  360.       }
  361.       this.Clip._x += this.XStep / 2;
  362.    }
  363.    else if(SwimValue == G_MOVE_UP_LEFT)
  364.    {
  365.       this.Direction = G_LEFT_DIRECTION;
  366.       if(ClipFrame != this.ClipUpLeftSwim)
  367.       {
  368.          this.Clip.gotoAndStop(this.ClipUpLeftSwim);
  369.       }
  370.       this.Clip._x -= this.XStep / 2;
  371.       this.Clip._y -= this.YStep / 2;
  372.    }
  373.    else if(SwimValue == G_MOVE_UP_RIGHT)
  374.    {
  375.       this.Direction = G_RIGHT_DIRECTION;
  376.       if(ClipFrame != this.ClipUpRightSwim)
  377.       {
  378.          this.Clip.gotoAndStop(this.ClipUpRightSwim);
  379.       }
  380.       this.Clip._x += this.XStep / 2;
  381.       this.Clip._y -= this.YStep / 2;
  382.    }
  383.    else if(SwimValue == G_MOVE_DOWN_LEFT)
  384.    {
  385.       this.Direction = G_LEFT_DIRECTION;
  386.       if(ClipFrame != this.ClipDownLeftSwim)
  387.       {
  388.          this.Clip.gotoAndStop(this.ClipDownLeftSwim);
  389.       }
  390.       this.Clip._x -= this.XStep / 2;
  391.       this.Clip._y += this.YStep / 2;
  392.    }
  393.    else if(SwimValue == G_MOVE_DOWN_RIGHT)
  394.    {
  395.       this.Direction = G_RIGHT_DIRECTION;
  396.       if(ClipFrame != this.ClipDownRightSwim)
  397.       {
  398.          this.Clip.gotoAndStop(this.ClipDownRightSwim);
  399.       }
  400.       this.Clip._x += this.XStep / 2;
  401.       this.Clip._y += this.YStep / 2;
  402.    }
  403.    else if(SwimValue == G_MOVE_UP)
  404.    {
  405.       if(this.Direction == G_LEFT_DIRECTION)
  406.       {
  407.          if(ClipFrame != this.ClipUpLeftSwim)
  408.          {
  409.             this.Clip.gotoAndStop(this.ClipUpLeftSwim);
  410.          }
  411.       }
  412.       else if(ClipFrame != this.ClipUpRightSwim)
  413.       {
  414.          this.Clip.gotoAndStop(this.ClipUpRightSwim);
  415.       }
  416.       this.Clip._y -= this.YStep / 2;
  417.    }
  418.    else if(SwimValue == G_MOVE_DOWN)
  419.    {
  420.       if(this.Direction == G_LEFT_DIRECTION)
  421.       {
  422.          if(ClipFrame != this.ClipDownLeftSwim)
  423.          {
  424.             this.Clip.gotoAndStop(this.ClipDownLeftSwim);
  425.          }
  426.       }
  427.       else if(ClipFrame != this.ClipDownRightSwim)
  428.       {
  429.          this.Clip.gotoAndStop(this.ClipDownRightSwim);
  430.       }
  431.       this.Clip._y += this.YStep / 2;
  432.    }
  433.    else
  434.    {
  435.       if(this.Direction == G_LEFT_DIRECTION)
  436.       {
  437.          if(ClipFrame != this.ClipLeftSwimBreak)
  438.          {
  439.             this.Clip.gotoAndStop(this.ClipLeftSwimBreak);
  440.          }
  441.       }
  442.       else if(ClipFrame != this.ClipRightSwimBreak)
  443.       {
  444.          this.Clip.gotoAndStop(this.ClipRightSwimBreak);
  445.       }
  446.       this.Clip._y += this.YStep / 4;
  447.    }
  448.    this.SwimValue = 1;
  449. };
  450. CSprite.prototype.IsJumpingFromWall = function()
  451. {
  452.    var ClipFrame = this.Clip._currentFrame;
  453.    return ClipFrame == this.ClipWallToRightJump || ClipFrame == this.ClipWallToLeftJump;
  454. };
  455. CSprite.prototype.IsWaitingOnWall = function()
  456. {
  457.    var ClipFrame = this.Clip._currentFrame;
  458.    return ClipFrame == this.ClipWallToRightBreak || ClipFrame == this.ClipWallToLeftBreak;
  459. };
  460. CSprite.prototype.IsEndWallJump = function()
  461. {
  462.    return this.ArrayCounter == this.WallJumpArray.length;
  463. };
  464. CSprite.prototype.IsHittingWallsArray = function(WallsMovieClipArray)
  465. {
  466.    var SpriteBounds = this.Clip.getBounds(_root);
  467.    var ValX;
  468.    var CptArray;
  469.    var HitTestValue;
  470.    var CurrentWall;
  471.    if(this.Direction == G_LEFT_DIRECTION)
  472.    {
  473.       ValX = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  474.    }
  475.    else
  476.    {
  477.       ValX = SpriteBounds.xMax - (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  478.    }
  479.    HitTestValue = 0;
  480.    CptArray = 0;
  481.    while(CptArray < WallsMovieClipArray.length && !HitTestValue)
  482.    {
  483.       CurrentWall = WallsMovieClipArray[CptArray];
  484.       HitTestValue = CurrentWall.hitTest(ValX,SpriteBounds.yMin,true) && CurrentWall.hitTest(ValX,SpriteBounds.yMax,true);
  485.       CptArray++;
  486.    }
  487.    if(HitTestValue)
  488.    {
  489.       CptArray--;
  490.       this.HitWallNum = CptArray;
  491.    }
  492.    return HitTestValue;
  493. };
  494. CSprite.prototype.AdjustClipOnWall = function(WallsMovieClipArray)
  495. {
  496.    var CurrentWall;
  497.    var SpriteBounds = this.Clip.getBounds(_root);
  498.    CurrentWall = WallsMovieClipArray[this.HitWallNum];
  499.    if(this.Direction == G_LEFT_DIRECTION)
  500.    {
  501.       this.Clip._x += CurrentWall._x - SpriteBounds.xMax;
  502.    }
  503.    else
  504.    {
  505.       this.Clip._x += CurrentWall._x - SpriteBounds.xMin;
  506.    }
  507. };
  508. CSprite.prototype.IsHittingWallJumping = function(WallMovieClip)
  509. {
  510.    var SpriteBounds = this.Clip.getBounds(_root);
  511.    var ValX;
  512.    var IncVal;
  513.    var HitVal;
  514.    var Cpt;
  515.    if(this.Direction == G_LEFT_DIRECTION)
  516.    {
  517.       ValX = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  518.    }
  519.    else
  520.    {
  521.       ValX = SpriteBounds.xMax - (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  522.    }
  523.    return WallMovieClip.hitTest(ValX,SpriteBounds.yMin,true) && WallMovieClip.hitTest(ValX,SpriteBounds.yMax,true) && 1 < this.ArrayCounter;
  524. };
  525. CSprite.prototype.StartWaitOnWall = function()
  526. {
  527.    this.ArrayCounter = 0;
  528.    if(this.Direction == G_LEFT_DIRECTION)
  529.    {
  530.       this.Clip.gotoAndStop(this.ClipWallToRightBreak);
  531.       this.Direction = G_RIGHT_DIRECTION;
  532.    }
  533.    else
  534.    {
  535.       this.Clip.gotoAndStop(this.ClipWallToLeftBreak);
  536.       this.Direction = G_LEFT_DIRECTION;
  537.    }
  538. };
  539. CSprite.prototype.StartWallJump = function(WallMoveValue)
  540. {
  541.    this.ArrayCounter = 0;
  542.    if(this.Direction == G_LEFT_DIRECTION && WallMoveValue == G_MOVE_LEFT)
  543.    {
  544.       this.Clip.gotoAndStop(this.ClipWallToLeftJump);
  545.       this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
  546.       this.ArrayCounter = this.ArrayCounter + 1;
  547.    }
  548.    else if(this.Direction == G_RIGHT_DIRECTION && WallMoveValue == G_MOVE_RIGHT)
  549.    {
  550.       this.Clip.gotoAndStop(this.ClipWallToRightJump);
  551.       this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
  552.       this.ArrayCounter = this.ArrayCounter + 1;
  553.    }
  554.    else if(WallMoveValue == G_MOVE_DOWN)
  555.    {
  556.       this.Clip.gotoAndStop(this.ClipFall);
  557.       if(this.Direction == G_LEFT_DIRECTION)
  558.       {
  559.          this.Clip._x -= 15;
  560.       }
  561.       else
  562.       {
  563.          this.Clip._x += 15;
  564.       }
  565.    }
  566. };
  567. CSprite.prototype.WallJump = function()
  568. {
  569.    if(this.Direction == G_LEFT_DIRECTION)
  570.    {
  571.       this.Clip._x -= G_STEP_WHEN_JUMPING + 4;
  572.    }
  573.    else
  574.    {
  575.       this.Clip._x += G_STEP_WHEN_JUMPING + 4;
  576.    }
  577.    this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
  578.    this.ArrayCounter = this.ArrayCounter + 1;
  579. };
  580. CSprite.prototype.EndWallJump = function()
  581. {
  582.    if(this.Direction == G_LEFT_DIRECTION)
  583.    {
  584.       this.Clip.gotoAndStop(this.ClipLeftStepFall);
  585.    }
  586.    else
  587.    {
  588.       this.Clip.gotoAndStop(this.ClipRightStepFall);
  589.    }
  590. };
  591. CSprite.prototype.GetMovementKey = function()
  592. {
  593.    if(Key.isDown(this.UpKey) && Key.isDown(this.LeftKey))
  594.    {
  595.       return G_MOVE_UP_LEFT;
  596.    }
  597.    if(Key.isDown(this.UpKey) && Key.isDown(this.RightKey))
  598.    {
  599.       return G_MOVE_UP_RIGHT;
  600.    }
  601.    if(Key.isDown(this.DownKey) && Key.isDown(this.LeftKey))
  602.    {
  603.       return G_MOVE_DOWN_LEFT;
  604.    }
  605.    if(Key.isDown(this.DownKey) && Key.isDown(this.RightKey))
  606.    {
  607.       return G_MOVE_DOWN_RIGHT;
  608.    }
  609.    if(Key.isDown(this.RightKey))
  610.    {
  611.       return G_MOVE_RIGHT;
  612.    }
  613.    if(Key.isDown(this.LeftKey))
  614.    {
  615.       return G_MOVE_LEFT;
  616.    }
  617.    if(Key.isDown(this.UpKey))
  618.    {
  619.       return G_MOVE_UP;
  620.    }
  621.    if(Key.isDown(this.DownKey))
  622.    {
  623.       return G_MOVE_DOWN;
  624.    }
  625.    return G_NO_MOVEMENT;
  626. };
  627. CSprite.prototype.Move = function(MoveValue)
  628. {
  629.    var ClipFrame = this.Clip._currentFrame;
  630.    if(MoveValue == G_MOVE_RIGHT)
  631.    {
  632.       this.Direction = G_RIGHT_DIRECTION;
  633.       if(ClipFrame != this.ClipRightStep)
  634.       {
  635.          this.Clip.gotoAndStop(this.ClipRightStep);
  636.       }
  637.       this.Clip._x += this.XStep;
  638.    }
  639.    else if(MoveValue == G_MOVE_LEFT)
  640.    {
  641.       this.Direction = G_LEFT_DIRECTION;
  642.       if(ClipFrame != this.ClipLeftStep)
  643.       {
  644.          this.Clip.gotoAndStop(this.ClipLeftStep);
  645.       }
  646.       this.Clip._x -= this.XStep;
  647.    }
  648.    else if(this.Direction == G_LEFT_DIRECTION)
  649.    {
  650.       if(ClipFrame != this.ClipLeftBreak)
  651.       {
  652.          this.Clip.gotoAndStop(this.ClipLeftBreak);
  653.       }
  654.    }
  655.    else if(ClipFrame != this.ClipRightBreak)
  656.    {
  657.       this.Clip.gotoAndStop(this.ClipRightBreak);
  658.    }
  659. };
  660. CSprite.prototype.IsJumpingMove = function(MoveValue)
  661. {
  662.    return MoveValue == G_MOVE_UP_LEFT || MoveValue == G_MOVE_UP || MoveValue == G_MOVE_UP_RIGHT;
  663. };
  664. CSprite.prototype.IsThrowingShuriken = function()
  665. {
  666.    if(0 < this.ThrowShuriken)
  667.    {
  668.       return 1;
  669.    }
  670.    return 0;
  671. };
  672. CSprite.prototype.IsShurikenKeyPressed = function()
  673. {
  674.    return Key.isDown(this.ShurikenKey);
  675. };
  676. CSprite.prototype.InitThrowShuriken = function()
  677. {
  678.    this.ThrowShuriken = 4;
  679. };
  680. CSprite.prototype.HasShurikens = function()
  681. {
  682.    return this.NumOfShurikens;
  683. };
  684. CSprite.prototype.ContinueThrowShuriken = function()
  685. {
  686.    this.ThrowShuriken--;
  687. };
  688. CSprite.prototype.IsEndThrowShuriken = function()
  689. {
  690.    return !this.ThrowShuriken;
  691. };
  692. CSprite.prototype.CreateShuriken = function()
  693. {
  694.    var CptArray;
  695.    CptArray = 0;
  696.    while(this.ShurikensArray[CptArray]._visible)
  697.    {
  698.       CptArray++;
  699.    }
  700.    if(this.Direction == G_RIGHT_DIRECTION)
  701.    {
  702.       this.ShurikensArray[CptArray].XDirection = 1;
  703.    }
  704.    else
  705.    {
  706.       this.ShurikensArray[CptArray].XDirection = -1;
  707.    }
  708.    this.ShurikensArray[CptArray]._x = this.Clip._x;
  709.    this.ShurikensArray[CptArray]._y = this.Clip._y;
  710.    this.ShurikensArray[CptArray]._visible = 1;
  711.    this.NumOfShurikens--;
  712. };
  713. CSprite.prototype.ClearShurikens = function()
  714. {
  715.    var CptArray;
  716.    CptArray = 0;
  717.    while(CptArray < this.ShurikensArray.length)
  718.    {
  719.       this.ShurikensArray[CptArray]._visible = 0;
  720.       CptArray++;
  721.    }
  722. };
  723. CSprite.prototype.MoveShurikens = function()
  724. {
  725.    var CptArray;
  726.    var InScreen;
  727.    CptArray = 0;
  728.    while(CptArray < this.ShurikensArray.length)
  729.    {
  730.       InScreen = this.ShurikensArray[CptArray]._x >= 0 && this.ShurikensArray[CptArray]._x < G_SCREEN_WIDTH;
  731.       if(this.ShurikensArray[CptArray]._visible && InScreen)
  732.       {
  733.          this.ShurikensArray[CptArray]._x += this.ShurikensArray[CptArray].XDirection * this.ShurikensSpeed;
  734.       }
  735.       else
  736.       {
  737.          this.ShurikensArray[CptArray]._visible = 0;
  738.       }
  739.       CptArray++;
  740.    }
  741. };
  742. CSprite.prototype.StartThrowShurikenOnPlatforms = function()
  743. {
  744.    var CurrentFrame = this.Clip._currentFrame;
  745.    if(CurrentFrame == this.ClipRightStep)
  746.    {
  747.       this.Clip.gotoAndStop(this.ClipRightThrowShurikenBreak);
  748.    }
  749.    else if(CurrentFrame == this.ClipLeftStep)
  750.    {
  751.       this.Clip.gotoAndStop(this.ClipLeftThrowShurikenBreak);
  752.    }
  753.    else if(this.Direction == G_RIGHT_DIRECTION)
  754.    {
  755.       this.Clip.gotoAndStop(this.ClipRightThrowShurikenBreak);
  756.    }
  757.    else
  758.    {
  759.       this.Clip.gotoAndStop(this.ClipLeftThrowShurikenBreak);
  760.    }
  761. };
  762. CSprite.prototype.IsSabreKeyPressedAfterRelease = function()
  763. {
  764.    if(Key.isDown(this.SabreKey) && this.SabreKeyRelease)
  765.    {
  766.       this.SabreKeyRelease = 0;
  767.       return 1;
  768.    }
  769.    return 0;
  770. };
  771. CSprite.prototype.TestSabreKeyRelease = function()
  772. {
  773.    if(!Key.isDown(this.SabreKey))
  774.    {
  775.       this.SabreKeyRelease = 1;
  776.    }
  777. };
  778. CSprite.prototype.InitSabreHit = function()
  779. {
  780.    this.SabreHit = 2;
  781. };
  782. CSprite.prototype.StartSabreHitOnPlatforms = function()
  783. {
  784.    var CurrentFrame = this.Clip._currentFrame;
  785.    if(CurrentFrame == this.ClipRightStep)
  786.    {
  787.       this.Clip.gotoAndStop(this.ClipRightSabreBreak);
  788.    }
  789.    else if(CurrentFrame == this.ClipLeftStep)
  790.    {
  791.       this.Clip.gotoAndStop(this.ClipLeftSabreBreak);
  792.    }
  793.    else if(this.Direction == G_RIGHT_DIRECTION)
  794.    {
  795.       this.Clip.gotoAndStop(this.ClipRightSabreBreak);
  796.    }
  797.    else
  798.    {
  799.       this.Clip.gotoAndStop(this.ClipLeftSabreBreak);
  800.    }
  801. };
  802. CSprite.prototype.IsHittingWithSabre = function()
  803. {
  804.    if(0 < this.SabreHit)
  805.    {
  806.       return 1;
  807.    }
  808.    return 0;
  809. };
  810. CSprite.prototype.SabreHit = function(EnemiesObjArray)
  811. {
  812.    var HitValue;
  813.    var CptArray;
  814.    var SpriteBounds;
  815.    var CurrentEnemy;
  816.    var XValue;
  817.    SpriteBounds = this.Clip.getBounds(_root);
  818.    if(this.Direction == G_RIGHT_DIRECTION)
  819.    {
  820.       XValue = SpriteBounds.xMax;
  821.    }
  822.    else
  823.    {
  824.       XValue = SpriteBounds.xMin;
  825.    }
  826.    HitValue = 0;
  827.    CptArray = 0;
  828.    while(!HitValue && CptArray < EnemiesObjArray.length)
  829.    {
  830.       CurrentEnemy = EnemiesObjArray[CptArray];
  831.       HitValue = CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMin,true) || CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMax,true) || CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMin + (SpriteBounds.yMax - SpriteBounds.yMin) / 2,true);
  832.       CptArray++;
  833.    }
  834.    CptArray--;
  835.    if(HitValue)
  836.    {
  837.       return CptArray;
  838.    }
  839.    return 0;
  840. };
  841. CSprite.prototype.ContinueSabreHit = function()
  842. {
  843.    this.SabreHit -= 1;
  844. };
  845. CSprite.prototype.IsEndSabreHit = function()
  846. {
  847.    return !this.SabreHit;
  848. };
  849. CSprite.prototype.IsBlinking = function()
  850. {
  851.    return this.BlinkValue;
  852. };
  853. CSprite.prototype.IsTouchedByEnemy = function(ArrayOfEnemiesObj)
  854. {
  855.    var HitValue;
  856.    var CptArray;
  857.    var SpriteBounds;
  858.    var CurrentEnemy;
  859.    var XValue1;
  860.    var XValue2;
  861.    var YValue;
  862.    var YInc;
  863.    SpriteBounds = this.Clip.getBounds(_root);
  864.    if(this.Direction == G_RIGHT_DIRECTION)
  865.    {
  866.       XValue1 = SpriteBounds.xMin;
  867.    }
  868.    else
  869.    {
  870.       XValue1 = SpriteBounds.xMax;
  871.    }
  872.    XValue2 = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
  873.    YInc = (SpriteBounds.yMax - SpriteBounds.yMin) / 3;
  874.    HitValue = 0;
  875.    CptArray = 0;
  876.    while(!HitValue && CptArray < ArrayOfEnemiesObj.length)
  877.    {
  878.       YValue = SpriteBounds.yMin;
  879.       while(!HitValue && YValue < SpriteBounds.yMax)
  880.       {
  881.          HitValue = ArrayOfEnemiesObj[CptArray].Clip.hitTest(XValue1,YValue,true) || ArrayOfEnemiesObj[CptArray].Clip.hitTest(XValue2,YValue,true);
  882.          YValue += YInc;
  883.       }
  884.       CptArray++;
  885.    }
  886.    return HitValue;
  887. };
  888. CSprite.prototype.TouchedByEnemyControl = function()
  889. {
  890.    this.BlinkValue = G_NUM_OF_BLINKS;
  891.    this.NumOfPower--;
  892. };
  893. CSprite.prototype.ContinueBlink = function()
  894. {
  895.    if(this.BlinkValue & 1)
  896.    {
  897.       this.Clip._visible = 1;
  898.    }
  899.    else
  900.    {
  901.       this.Clip._visible = 0;
  902.    }
  903.    this.BlinkValue--;
  904. };
  905.